/**
 * Licensee: Universidad de Almeria
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class ListPractica1Data {
	private static final int ROW_COUNT = 100;
	
public void listTestData() throws PersistentException {
		System.out.println("Listing Registro...");
		agenda.Registro[] agendaRegistros = agenda.RegistroDAO.listRegistroByQuery(null, null);
		int length = Math.min(agendaRegistros.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(agendaRegistros[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
	}
	
	public void listByCriteria() throws PersistentException  {
		System.out.println("Listing Registro by Criteria...");
		agenda.RegistroCriteria registroCriteria = new agenda.RegistroCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//registroCriteria.telefono.eq();
		registroCriteria.setMaxResults(ROW_COUNT);
		agenda.Registro[] agendaRegistros = registroCriteria.listRegistro();
		int length =agendaRegistros== null ? 0 : Math.min(agendaRegistros.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(agendaRegistros[i]);
		}
		System.out.println(length + " Registro record(s) retrieved."); 
		
	}
	
	public static void main(String[] args) {
		try {
			ListPractica1Data listPractica1Data = new ListPractica1Data();
			try {
				listPractica1Data.listTestData();
				//listPractica1Data.listByCriteria(telefono);
			}
			finally {
				agenda.Practica1PersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
